home *** CD-ROM | disk | FTP | other *** search
- /*
- * This file contains the code necessary to switch
- * tasks on an m680x0 linux machine.
- * The following LTSS_ constants must be changed if the m68k_struct in
- * include/linux/sched.h is changed.
- * The LBI_CPU constant must be changed if the boot_info structure is
- * changed.
- */
-
- LFLUSH_I_AND_D = 0x00000808
- LBI_CPU = 4
- LTSS_SR = 48
- LTSS_REGS = 0
- LTSS_FS = 50
- LTSS_CRP = 60
- LTSS_FPREGS = 68
- LTSS_FPCNTL = 164
- LTSS_FPSTATE = 176
-
- .text
-
- .globl _resume
- .even
- _resume:
- /* current tasks task_struct */
- movel _current,a0
-
- /* offset of tss struct (processor state) from beginning
- of task struct */
- movel sp@(8),a1
- addl a1,a0
-
- /* save sr */
- movew sr,a0@(LTSS_SR)
-
- /* disable interrupts */
- oriw #0x0700,sr
-
- /* save fs (sfc,dfc) (may be pointing to kernel memory) */
- movec sfc,d0
- movew d0,a0@(LTSS_FS)
-
- /* save non-scratch registers */
- moveml d2-d7/a2-a7,a0@(LTSS_REGS)
-
- /* save floating point state */
- fsave a0@(LTSS_FPSTATE)
- tstw a0@(LTSS_FPSTATE)
- beqs 1f /* NULL state, no need to save regs */
- fmovemx fp0-fp7,a0@(LTSS_FPREGS)
- | fmovem fpiar/fpcr/fpsr,a0@(LTSS_FPCNTL)
- fmovem fpcr/fpsr,a0@(LTSS_FPCNTL)
- 1:
-
- /* switch current task */
- movel sp@(4),a0
- movel a0,_current
- /* get pointer to tss struct */
- addl a1,a0
-
- /* 68040 ? */
- btst #2,_boot_info+LBI_CPU+3
- bnes 1f
-
- /*
- * switch address space
- */
-
- /* flush MC68030/MC68020 caches (they are virtually addressed) */
- movec cacr,d0
- oril #LFLUSH_I_AND_D,d0
- movec d0,cacr
-
- /* switch the root pointer */
- pmove a0@(LTSS_CRP),crp
-
- /* flush address translation cache (probably not needed */
- pflusha
-
- bras 2f /* skip m68040 stuff */
-
- 1:
- /*
- * switch address space
- */
-
- /* flush address translation cache (user entries) */
- .word 0xf510 /* pflushan */
-
- /* switch the root pointer */
- movel a0@(LTSS_CRP+4),d0
- .long 0x4e7b0806 /* movec d0,urp */
-
-
- 2:
- /* restore floating point unit state */
- tstw a0@(LTSS_FPSTATE)
- beqs 1f /* NULL state; no need to load regs */
- fmovemx a0@(LTSS_FPREGS),fp0-fp7
- | fmovem a0@(LTSS_FPCNTL),fpiar/fpcr/fpsr
- fmovem a0@(LTSS_FPCNTL),fpcr/fpsr
- 1:
- frestore a0@(LTSS_FPSTATE)
-
- /* restore non-scratch registers */
- moveml a0@(LTSS_REGS),d2-d7/a2-a7
-
- /* restore fs (sfc,dfc) */
- movew a0@(LTSS_FS),a1
- movec a1,sfc
- movec a1,dfc
-
- /* restore status register */
- movew a0@(LTSS_SR),sr
-
- rts
-